package com.leanin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.leanin.domain.MsgInfo;
import com.leanin.response.DataOutResponse;
import com.leanin.service.MsgInfoService;

@RestController
@RequestMapping(value="msg")
public class MsgInfoController {

	@Autowired
	private MsgInfoService msgInfoService;
	
	@GetMapping("findMsgListByTypeId")
	public DataOutResponse findMsgListByTypeId(@RequestParam Integer page,@RequestParam Integer pageSize,
											   @RequestParam(required=false) Long typeId,@RequestParam(required=false) String msgName) {
		return msgInfoService.findMsgListByTypeId(page, pageSize, typeId, msgName);
	}
	
	@GetMapping("logoutMsg")
	public DataOutResponse logoutMsg(@RequestParam String msgId,@RequestParam int status) {
		return msgInfoService.updateMsgStatus(msgId, status);
	}
	
	@PostMapping("addMsgInfo")
	public DataOutResponse addMsgInfo(@RequestBody MsgInfo msgInfo) {
		return msgInfoService.addMsgInfo(msgInfo);
	}
	
	@PostMapping("updateMsgInfo")
	public DataOutResponse updateMsgInfo(@RequestBody MsgInfo msgInfo) {
		return msgInfoService.updateMsgInfo(msgInfo);
	}
	
	@GetMapping("findMsgInfoById")
	public DataOutResponse findMsgInfoById(@RequestParam String msgId) {
		return msgInfoService.findMsgInfoById(msgId);
	}
}
